<?php
/********************************************************
 *
 * 此文件的作用:
 *		市场部后台控制器
 *
 * @copyright Copyright (c) 2008-2009
 * @author 刘昌功 lcg635@126.com
 *
 ********************************************************/
defined('APP_DIR') or die('404 Not Found');

FLEA::loadClass('Common_AdminAction');

class Controller_AdminProperty extends Common_AdminAction {
	function __construct($ctlName)   {
		parent::__construct($ctlName);
	}
	
	function lostPropertyList() {
		$_LostProperty = FLEA::getSingleton('Model_LostProperty');
		$ui = FLEA::initWebControls();
		$page = $this->saveGet('page');
		$viewData = $_LostProperty->getList('', $page, 15, true);
		$viewData['pagerData'] = $ui->control('pagernav', 'pagenav',
			array('pager'=>$viewData['pagerData'],'controller'=>'AdminProperty', 'action'=>'lostPropertyList' ),
			true
		);
		$this->_out('lostProperty/lostPropertyList', $viewData);
	}
	
	function lostPropertyAdd() {
		$_lostProperty = FLEA::getSingleton('Model_lostProperty');
		if ( $this->_isPOST() ) {
			$result = $_lostProperty->insert($_POST);
			$this->_throwRemind('登记成功', '失物已经登记', null, $this->_url('lostPropertyList'));
		} else {
			$number = $_lostProperty->getCurrentNumber();
			$viewData = array(
				'number' => $number
			);
			$this->_out('lostProperty/lostPropertyAdd', $viewData);
		}
	}	
		
	function lostPropertyEdit() {
		$_lostProperty = FLEA::getSingleton('Model_lostProperty');
		if ( $this->_isPOST() ) {
			$result = $_lostProperty->update($_POST);
			$this->_throwRemind('修改成功', '失物信息修改成功', null, $this->_url('lostPropertyList'));
		} else {
			$property_id = $this->saveGet('property_id');
			$property = $_lostProperty->getInfo($property_id);
			//dump($property);
			$this->_out('lostProperty/lostPropertyEdit', $property);
		}
	}
	
	function LostPropertyDelete() {
		$_lostProperty = FLEA::getSingleton('Model_lostProperty');
		$property_id = $this->saveGet('property_id');
		$_lostProperty->delete($property_id);
		redirect($_SERVER['HTTP_REFERER']);
	}
	
	function test() {
		$_lostProperty = FLEA::getSingleton('Model_lostProperty');
		echo $_lostProperty->getCurrentNumber();
	}
	
}
